#include <iostream>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
using namespace std;
void handle(int signo)
{
    pid_t id;
    while ((id = waitpid(-1, nullptr, WNOHANG)) > 0)
    {
        cout << "wait success"
             << "   " << id << endl;
    }
    cout << "----------" << getpid() << endl;
}
int main()
{
    signal(SIGCLD, handle);
    pid_t pid = fork();
    if (pid < 0)
        return 0;
    if (pid == 0)
    {
        cout << "child work...."
             << " " << getpid() << endl;
        sleep(5);
        exit(1);
    }
    else
    {
        while (1)
        {
            cout << "parent work...." << endl;
            cout << getpid() << endl;
            sleep(1);
        }
    }
    return 0;
}